import {Pipe, PipeTransform} from '@angular/core';

/**
 * 租机机器状态
 */
export const rentplaneMachineStatusArrs = [
  {value: 0, label: '正常', color: '#008000'},
  {value: 1, label: '冻结', color: '#FF6600'},
  {value: 2, label: '已出库', color: '#FF0000'}
];

@Pipe({
  name: 'rentplaneMachineStatus'
})
export class RentplaneMachineStatusPipe implements PipeTransform {
  transform(value: any, type?: string) {
    let tempObj: any = rentplaneMachineStatusArrs.find((item: any) => item.value === value);
    if (type && type === 'color') {
      return tempObj?.color || '#909399';
    } else {
      return tempObj?.label || '-';
    }
  }
}

// 设备类型 1：零售机、2：监管机、3：资源机、4：权益机
export const rentplaneDeviceTypeArrs = [
  {value: 1, label: '零售机', color: '#008000'},
  {value: 2, label: '监管机', color: '#FF6600'},
  {value: 3, label: '资源机', color: '#FF6600'},
  {value: 4, label: '权益机', color: '#FF0000'}
];

@Pipe({
  name: 'rentplaneDeviceType'
})
export class RentplaneDeviceTypePipe implements PipeTransform {
  transform(value: any, type?: string) {
    let tempObj: any = rentplaneDeviceTypeArrs.find((item: any) => item.value == value);
    if (type && type === 'color') {
      return tempObj?.color || '#909399';
    } else {
      return tempObj?.label || '-';
    }
  }
}

// 出库类型 1：出租手机、2：售出手机
export const rentplaneOutTypeArrs = [
  {value: 1, label: '出租手机', color: '#008000'},
  {value: 2, label: '售出手机', color: '#FF6600'}
];

@Pipe({
  name: 'rentplaneOutType'
})
export class RentplaneOutTypePipe implements PipeTransform {
  transform(value: any, type?: string) {
    let tempObj: any = rentplaneOutTypeArrs.find((item: any) => item.value == value);
    if (type && type === 'color') {
      return tempObj?.color || '#909399';
    } else {
      return tempObj?.label || '-';
    }
  }
}